<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%String ref = request.getHeader("REFERER");%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>广东省传播平台-合同详情展开页</title>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/common.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/css/tag.css" />
<script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.js"></script>
<link href="<%=path%>/js/My97DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript">
			function doSubmit(url){
					document.forms[0].action=url;
					document.forms[0].submit();
			}
			
					//删除合同动作
	     function delContract(contractID){
			if(confirm('确定删除该条记录？')){
			var url = encodeURI(encodeURI("deleteContract.action?contractID=" +contractID));
				$.ajax({
			        url: url,
			        type:"POST",
			        cache:false,
			        success: function(message)
			        {
				    	if(message == "success")
				    	{
			        		alert("合同删除成功！");
			        		window.location.href="contractlist.action";
			        	}
			        	else if(message =="Nosuccess")
			        	{
				    		alert("媒体正在使用，合同删除失败！");
				    		//window.location.href="contractlist.action";
			        	}
			        	else if(message =="isDelete")
				    	{
				    		alert("该合同不存在，删除失败！");
				    		window.location.href="contractlist.action";
				    	}
				    	else if(message =="error")
				    	{
				    		window.location.href="contractlist.action";
				    	}
			   		}
		     	});
			}
	    }
	    
	    //编辑
	    function contractMofify(contractID){
		var url = encodeURI(encodeURI("turnToContractModify.action?contractID=" +contractID));
		window.location.href=url;
	    }
	    //下载文件
	    function downloadFile(fileName)
	    {
	      var url = encodeURI(encodeURI("downLoadContractFileName.action?fileName=" +fileName));
	      window.location.href=url;
	    }
	   $(function(){
        //selectNav('nav1');
    });
    function getback()
    {
       
       history.go(-1);
   //    var toType = ${toType}; 
   //    if(toType=='2')
   //    {
   //         doSubmit('mediaPriceAction.action');
   //    }
   //    else 
    //   {
   //       doSubmit('contractlist.action');
    //   }
    }
	</script>
</head>

<body>
<!-- 顶栏start -->
<jsp:include page="../common/top.jsp"></jsp:include>
<!-- 顶部start -->
<div id="main">
	<div class="body">
		<jsp:include page="../common/nav.jsp"></jsp:include>
		
		<!-- 主体 -->
		<div class="main_body">
		<form action="" method="post">
			<table class="condition" style="width:100%; font-size:14px; font-weight:bold; color:#000000;" align="center">
				<tr>
					<td>
					    <s:if test="%{null != contractDetail}">
						<input type="button" class="btn-title" value="新增" onclick="doSubmit('toAddContract.action');" />
						<s:if test="#session.logUser.usercity == contractDetail.contractCity">
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="btn-title" value="编辑" onclick="javascript:contractMofify('${contractDetail.contractID}');" />
						</s:if>
						<s:if test="#session.logUser.usercity == contractDetail.contractCity">
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="btn-title" value="删除" onclick="javascript:delContract('${contractDetail.contractID}');" />
						</s:if>
						</s:if>
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="btn-title" value="返回" onclick="getback();" />
					</td>
				</tr>
			</table>
			
			<div id="list_div">
				<table class="table_list"  style="width: 100%;">
				<s:if test="%{null ==contractDetail}">
							<tr>
								<th style="width: 150px; text-align: center; color: red" colspan="3">
									该条记录不存在或已删除！									
								</th>
							</tr>
				</s:if>
				<s:else>
					<tr class="bg" style="border-left: 2px solid #f37c20;">
						<th colspan="16" style="font-size:15px; padding-left:18px;">合同信息</th>
					</tr>
					<tr style="background:#f2f2f2;">
						<th style="border-style:solid dashed dashed solid;">合同编号</th>
						<th style="border-style:solid dashed dashed;">合同名称</th>
						<th style="border-style:solid dashed dashed;">供应商名称</th>
						<th style="border-style:solid dashed dashed;">供应商类型</th>
						<th style="border-style:solid dashed dashed;">归属地市</th>
						<th style="border-style:solid dashed dashed;">签约级别</th>
						<th style="border-style:solid dashed dashed;">部门科室</th>
						<th style="border-style:solid dashed dashed;">签约人</th>
						<th style="border-style:solid dashed dashed;">年度</th>
						<th style="border-style:solid dashed dashed;">开始时间</th>
						<th style="border-style:solid dashed dashed;">截止时间</th>
						<th style="border-style:solid dashed dashed;">合同类型</th>
						<th style="border-style:solid solid dashed dashed;">付款方式</th>
					</tr>
					<s:iterator value="contractDetail" id="contractDetail">
					<tr >
						<td style="border-style:dashed dashed solid solid;" title="${contractDetail.contractID}">
						${fn:substring(contractDetail.contractID, 0, 18) }
						</td>
						<td style="border-style:dashed dashed solid;" title="${contractDetail.contractName}">
						${fn:substring(contractDetail.contractName, 0, 10) }
						</td>
						<td style="border-style:dashed dashed solid;" title="${contractDetail.contractBName}">
						${fn:substring(contractDetail.contractBName, 0, 10) }
						</td>
						<td style="border-style:dashed dashed solid;">
						  <s:iterator value="dataListGYSLX" id="gyslx">
								<s:if test="#gyslx.id == #contractDetail.contractBType" >
									 ${gyslx.datavalue}
								</s:if>
						  </s:iterator>
						</td>
						<td style="border-style:dashed dashed solid;">
						   <s:iterator value="dataListCITY" id="city">
	                          <s:if test="#city.id == #contractDetail.contractCity">
	                              ${city.datavalue}
						     </s:if>
						   </s:iterator>
						</td>
						<td style="border-style:dashed dashed solid;" >
							<s:iterator value="dataListQYJB" id="qyjb">
	                          <s:if test="#qyjb.id == #contractDetail.contractLevel">
	                              ${qyjb.datavalue}
						     </s:if>
						   </s:iterator>
						</td>
						<td style="border-style:dashed dashed solid;" title="${contractDetail.contractDepartment}">
						${contractDetail.contractDepartment}
						</td>
						<td style="border-style:dashed dashed solid;" title="${contractDetail.contractor}" >
						${fn:substring(contractDetail.contractor, 0, 5) }
						</td>
						<td style="border-style:dashed dashed solid;">${contractDetail.contractYear}</td>
						<td style="border-style:dashed dashed solid;" title="${contractDetail.contractStartTime}">
						${fn:substring(contractDetail.contractStartTime, 0, 10) }
						</td>
						<td style="border-style:dashed dashed solid;" title="${contractDetail.contractEndTime}">
						${fn:substring(contractDetail.contractEndTime, 0, 10) }
						</td>
						<td style="border-style:dashed dashed solid;">
							<s:iterator value="dataListHTLX" id="htlx">
							  <s:if test="#htlx.id == #contractDetail.contractType">
							  ${htlx.datavalue}
							  </s:if>
							</s:iterator>
						</td>
						<td style="border-style:dashed solid solid dashed;">
							<s:iterator value="dataListFKFS" id="fkfs">
								 <s:if test="#fkfs.id == #contractDetail.contractPayment">
								 ${fkfs.datavalue}
								 </s:if>
							</s:iterator>
						</td>
					</tr>
					<tr style="background:#f2f2f2;">
						<th colspan="16" style="padding-left:37px; border-style:solid solid dashed;">简要描述</th>
					</tr>
					<tr style="text-align:left;">
						<td colspan="16" style="border-style:dashed solid solid;" title="${contractDetail.contractDescription}">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${fn:substring(contractDetail.contractDescription, 0, 120) }</td>
					</tr>
					<tr class="bg" style="border-left: 2px solid #f37c20;">
						<th colspan="16" style="font-size:15px; padding-left:18px;">合同对于签约媒体</th>
					</tr>
					<tr style="background:#f2f2f2;">
					<s:iterator status="stu" value="listMediaPrice" id="list">
						<s:if test="#stu.index == 0">
							<th style="border-style:solid dashed dashed solid;">媒体名称</th>
						</s:if>
						<s:else>
							<th style="border-style:solid dashed dashed dashed">媒体名称</th>
						</s:else>
					</s:iterator>
						<s:if test="conuml == 16">
							<th colspan="${conuml}" style="border-style:solid solid dashed solid"></th>
						</s:if>
						<s:else>
							<th colspan="${conuml}" style="border-style:solid solid dashed dashed;"></th>
						</s:else>
					</tr>
					<tr >
					<s:iterator status="stu" value="listMediaPrice" id="list">
						
						<s:if test="#stu.index == 0">
							<td style="border-style:dashed dashed solid solid;" title="${list.mediasumm.mediaName}">
								<a href="#" onclick="doSubmit('mediumDetailAction.action?priceID=${list.priceID}');"
								class="underline">${fn:substring(list.mediasumm.mediaName, 0, 5)}</a>
							</td>
						</s:if>
						<s:else>
							<td style="border-style:dashed dashed solid dashed" title="${list.mediasumm.mediaName}">
								<a href="#" onclick="doSubmit('mediumDetailAction.action?priceID=${list.priceID}');"
								class="underline">
								${fn:substring(list.mediasumm.mediaName, 0, 5) }
								</a>
							</td>
						</s:else>
					</s:iterator>
					<s:if test="conuml == 16">
							<td colspan="${conuml}" style="border-style:solid solid dashed solid"></td>
						</s:if>
						<s:else>
							<td colspan="${conuml}" style="border-style:solid solid dashed dashed;"></td>
						</s:else>
					</tr>
					<c:if test="${!empty contractDetail.contractFilename}">
						<tr class="bg" style="border-left: 2px solid #f37c20;">
							<th colspan="16" style="font-size:15px; padding-left:18px;">合约电子档</th>
						</tr>
						<tr style="text-align:left;">
							<td colspan="16">
							&nbsp;&nbsp;&nbsp;&nbsp;
							<img src="<%=path%>/images/hetong.jpg" width="20" height="20" align="absmiddle"/>
							${contractDetail.contractFilename}&nbsp;&nbsp;
							${contractFileSize}&nbsp;&nbsp;
							<a href="javascript:downloadFile('${contractDetail.contractFilename}');" title="下载"><img src="<%=path%>/images/download.gif" align="absmiddle" alt="下载" /></a>
							</td>
						</tr>
					</c:if>
					<tr class="bg" style="border-left: 2px solid #f37c20;">
						<th colspan="16" style="font-size:15px; padding-left:18px;">变更记录</th>
					</tr>
					<tr style="text-align:left;">
						<td colspan="16">
							<ul>	
							<s:iterator value="logList" id="list">
								<li style="height:30px; line-height:30px;">&nbsp;&nbsp;&nbsp;&nbsp;${list.content}。</li>
							</s:iterator>
							</ul>
						</td>
					</tr>
					</s:iterator>
				</s:else>
				  </table>
				</div>
			</form>
			</div>
		</div>
	</div>
</div>
<!-- 顶部end -->


<!-- 底部start -->
<div id="bottom">
	<div class="body">
		<label>版权所有&nbsp;&nbsp;&nbsp;&nbsp;2012东莞移动</label>
	</div>
</div>
<!-- 底部end -->
</body>
</html>
